#include <cstdio>
#include <map>
using namespace std;

int DP[105][105];
int MEM[105][105];
int num[105];
int N;
const int INF = -2147483647;

void initialize() {
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < N; ++j) {
            DP[i][j] = 0;
            MEM[i][j] = INF;
        }
    }
}

void input() {
    for(int i = 0; i < N; ++i) {
        scanf("%d", &num[i]);
    }
}

int winner_DP(int left, int right) {
    if(left == right) {
        return num[left];
    } else if(left < right) {
        if(MEM[left][right] == INF) {
            for(int i = left; i <= right; ++i) {
                int v = DP[left][i] - winner_DP(i + 1, right);
                if(MEM[left][right] < v) {
                    MEM[left][right] = v;
                }
            }
            for(int i = left; i <= right; ++i) {
                int v = DP[i][right] - winner_DP(left, i - 1);
                if(MEM[left][right] < v) {
                    MEM[left][right] = v;
                }
            }
        }
        return MEM[left][right];
    }
    return 0;
}

int cal() {
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < N; ++j) {
            for(int m = i; m <= j; ++m) {
                DP[i][j] += num[m];
            }
        }
    }

    return winner_DP(0, N - 1);
}

void output() {
    printf("%d\n", cal());
}

int main() {
    while(~scanf("%d", &N) && N > 0) {
        initialize();
        input();
        output();
    }
    return 0;
}
